package com.compass.doctor.ui.home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutExigencyItemBinding
import com.compass.doctor.databinding.LayoutNotificationItemBinding
import com.compass.doctor.utils.StringUtils
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.model.DoctorUrgency
import com.compass.framework.model.MenuItem
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 紧急代办Adapter
 * Date:2023/12/8 15:01
 */
class ExigencyAdapter : BaseRecyclerViewAdapter<DoctorUrgency, LayoutExigencyItemBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutExigencyItemBinding>,
        item: DoctorUrgency?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvTitle.text = item.title
            tvContent.text = item.description
            tvTime.text = DateUtils.getTimeDescriptionByDate(item.createTime)
            when (item.type) {
                1 -> {//问诊订单
                    ivNotification.background = (getDrawableResource(R.drawable.btn_oval_pale_green))
                    when(item.message.consultationType){
                        2->{
                            ivNotification.setImageResource(R.mipmap.icon_inquiry_phone)
                        }
                        3->{
                            ivNotification.setImageResource(R.mipmap.icon_inquiry_video)
                        }
                        else->{
                            ivNotification.setImageResource(R.mipmap.icon_inquiry_text)
                        }
                    }
                }

                2 ,6 -> {//处方申请
                    ivNotification.background = (getDrawableResource(R.drawable.btn_oval_pale_yellow))
                    ivNotification.setImageResource(R.mipmap.icon_inquiry_prescription)
                }

                3 -> {//会诊
                    ivNotification.background = (getDrawableResource(R.drawable.btn_oval_pale_yellow))
                    ivNotification.setImageResource(R.mipmap.icon_inquiry_consultation)

                }
                4 -> {//医护上门
                    ivNotification.background = (getDrawableResource(R.drawable.btn_oval_pale_yellow))
                    ivNotification.setImageResource(R.mipmap.icon_medical_care)

                }
                else -> {
                    ivNotification.background = (getDrawableResource(R.drawable.btn_oval_pale_blue))
                    ivNotification.setImageResource(R.mipmap.icon_inquiry_notification)
                }
            }


        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutExigencyItemBinding {
        return LayoutExigencyItemBinding.inflate(layoutInflater, parent, false)
    }
}